<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-pragma">{-# LANGUAGE Trustworthy #-}</span><span>
</span><span id="line-2"></span><span class="hs-pragma">{-# LANGUAGE NoImplicitPrelude, UnboxedTuples, MagicHash #-}</span><span>
</span><span id="line-3"></span><span>
</span><span id="line-4"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-5"></span><span class="hs-comment">-- |</span><span>
</span><span id="line-6"></span><span class="hs-comment">-- Module      :  Control.Concurrent.MVar</span><span>
</span><span id="line-7"></span><span class="hs-comment">-- Copyright   :  (c) The University of Glasgow 2001</span><span>
</span><span id="line-8"></span><span class="hs-comment">-- License     :  BSD-style (see the file libraries/base/LICENSE)</span><span>
</span><span id="line-9"></span><span class="hs-comment">-- </span><span>
</span><span id="line-10"></span><span class="hs-comment">-- Maintainer  :  libraries@haskell.org</span><span>
</span><span id="line-11"></span><span class="hs-comment">-- Stability   :  experimental</span><span>
</span><span id="line-12"></span><span class="hs-comment">-- Portability :  non-portable (concurrency)</span><span>
</span><span id="line-13"></span><span class="hs-comment">--</span><span>
</span><span id="line-14"></span><span class="hs-comment">-- An @'MVar' t@ is mutable location that is either empty or contains a</span><span>
</span><span id="line-15"></span><span class="hs-comment">-- value of type @t@.  It has two fundamental operations: 'putMVar'</span><span>
</span><span id="line-16"></span><span class="hs-comment">-- which fills an 'MVar' if it is empty and blocks otherwise, and</span><span>
</span><span id="line-17"></span><span class="hs-comment">-- 'takeMVar' which empties an 'MVar' if it is full and blocks</span><span>
</span><span id="line-18"></span><span class="hs-comment">-- otherwise.  They can be used in multiple different ways:</span><span>
</span><span id="line-19"></span><span class="hs-comment">--</span><span>
</span><span id="line-20"></span><span class="hs-comment">--   1. As synchronized mutable variables,</span><span>
</span><span id="line-21"></span><span class="hs-comment">--</span><span>
</span><span id="line-22"></span><span class="hs-comment">--   2. As channels, with 'takeMVar' and 'putMVar' as receive and send, and</span><span>
</span><span id="line-23"></span><span class="hs-comment">--</span><span>
</span><span id="line-24"></span><span class="hs-comment">--   3. As a binary semaphore @'MVar' ()@, with 'takeMVar' and 'putMVar' as</span><span>
</span><span id="line-25"></span><span class="hs-comment">--      wait and signal.</span><span>
</span><span id="line-26"></span><span class="hs-comment">--</span><span>
</span><span id="line-27"></span><span class="hs-comment">-- They were introduced in the paper</span><span>
</span><span id="line-28"></span><span class="hs-comment">-- &lt;https://www.haskell.org/ghc/docs/papers/concurrent-haskell.ps.gz &quot;Concurrent Haskell&quot;&gt;</span><span>
</span><span id="line-29"></span><span class="hs-comment">-- by Simon Peyton Jones, Andrew Gordon and Sigbjorn Finne, though</span><span>
</span><span id="line-30"></span><span class="hs-comment">-- some details of their implementation have since then changed (in</span><span>
</span><span id="line-31"></span><span class="hs-comment">-- particular, a put on a full 'MVar' used to error, but now merely</span><span>
</span><span id="line-32"></span><span class="hs-comment">-- blocks.)</span><span>
</span><span id="line-33"></span><span class="hs-comment">--</span><span>
</span><span id="line-34"></span><span class="hs-comment">-- === Applicability</span><span>
</span><span id="line-35"></span><span class="hs-comment">--</span><span>
</span><span id="line-36"></span><span class="hs-comment">-- 'MVar's offer more flexibility than 'Data.IORef.IORef's, but less flexibility</span><span>
</span><span id="line-37"></span><span class="hs-comment">-- than 'GHC.Conc.STM'.  They are appropriate for building synchronization</span><span>
</span><span id="line-38"></span><span class="hs-comment">-- primitives and performing simple interthread communication; however</span><span>
</span><span id="line-39"></span><span class="hs-comment">-- they are very simple and susceptible to race conditions, deadlocks or</span><span>
</span><span id="line-40"></span><span class="hs-comment">-- uncaught exceptions.  Do not use them if you need perform larger</span><span>
</span><span id="line-41"></span><span class="hs-comment">-- atomic operations such as reading from multiple variables: use 'GHC.Conc.STM'</span><span>
</span><span id="line-42"></span><span class="hs-comment">-- instead.</span><span>
</span><span id="line-43"></span><span class="hs-comment">--</span><span>
</span><span id="line-44"></span><span class="hs-comment">-- In particular, the &quot;bigger&quot; functions in this module ('swapMVar',</span><span>
</span><span id="line-45"></span><span class="hs-comment">-- 'withMVar', 'modifyMVar_' and 'modifyMVar') are simply</span><span>
</span><span id="line-46"></span><span class="hs-comment">-- the composition of a 'takeMVar' followed by a 'putMVar' with</span><span>
</span><span id="line-47"></span><span class="hs-comment">-- exception safety.</span><span>
</span><span id="line-48"></span><span class="hs-comment">-- These only have atomicity guarantees if all other threads</span><span>
</span><span id="line-49"></span><span class="hs-comment">-- perform a 'takeMVar' before a 'putMVar' as well;  otherwise, they may</span><span>
</span><span id="line-50"></span><span class="hs-comment">-- block.</span><span>
</span><span id="line-51"></span><span class="hs-comment">--</span><span>
</span><span id="line-52"></span><span class="hs-comment">-- === Fairness</span><span>
</span><span id="line-53"></span><span class="hs-comment">--</span><span>
</span><span id="line-54"></span><span class="hs-comment">-- No thread can be blocked indefinitely on an 'MVar' unless another</span><span>
</span><span id="line-55"></span><span class="hs-comment">-- thread holds that 'MVar' indefinitely.  One usual implementation of</span><span>
</span><span id="line-56"></span><span class="hs-comment">-- this fairness guarantee is that threads blocked on an 'MVar' are</span><span>
</span><span id="line-57"></span><span class="hs-comment">-- served in a first-in-first-out fashion, but this is not guaranteed</span><span>
</span><span id="line-58"></span><span class="hs-comment">-- in the semantics.</span><span>
</span><span id="line-59"></span><span class="hs-comment">--</span><span>
</span><span id="line-60"></span><span class="hs-comment">-- === Gotchas</span><span>
</span><span id="line-61"></span><span class="hs-comment">--</span><span>
</span><span id="line-62"></span><span class="hs-comment">-- Like many other Haskell data structures, 'MVar's are lazy.  This</span><span>
</span><span id="line-63"></span><span class="hs-comment">-- means that if you place an expensive unevaluated thunk inside an</span><span>
</span><span id="line-64"></span><span class="hs-comment">-- 'MVar', it will be evaluated by the thread that consumes it, not the</span><span>
</span><span id="line-65"></span><span class="hs-comment">-- thread that produced it.  Be sure to 'evaluate' values to be placed</span><span>
</span><span id="line-66"></span><span class="hs-comment">-- in an 'MVar' to the appropriate normal form, or utilize a strict</span><span>
</span><span id="line-67"></span><span class="hs-comment">-- MVar provided by the strict-concurrency package.</span><span>
</span><span id="line-68"></span><span class="hs-comment">--</span><span>
</span><span id="line-69"></span><span class="hs-comment">-- === Ordering</span><span>
</span><span id="line-70"></span><span class="hs-comment">--</span><span>
</span><span id="line-71"></span><span class="hs-comment">-- 'MVar' operations are always observed to take place in the order</span><span>
</span><span id="line-72"></span><span class="hs-comment">-- they are written in the program, regardless of the memory model of</span><span>
</span><span id="line-73"></span><span class="hs-comment">-- the underlying machine.  This is in contrast to 'Data.IORef.IORef' operations</span><span>
</span><span id="line-74"></span><span class="hs-comment">-- which may appear out-of-order to another thread in some cases.</span><span>
</span><span id="line-75"></span><span class="hs-comment">--</span><span>
</span><span id="line-76"></span><span class="hs-comment">-- === Example</span><span>
</span><span id="line-77"></span><span class="hs-comment">--</span><span>
</span><span id="line-78"></span><span class="hs-comment">-- Consider the following concurrent data structure, a skip channel.</span><span>
</span><span id="line-79"></span><span class="hs-comment">-- This is a channel for an intermittent source of high bandwidth</span><span>
</span><span id="line-80"></span><span class="hs-comment">-- information (for example, mouse movement events.)  Writing to the</span><span>
</span><span id="line-81"></span><span class="hs-comment">-- channel never blocks, and reading from the channel only returns the</span><span>
</span><span id="line-82"></span><span class="hs-comment">-- most recent value, or blocks if there are no new values.  Multiple</span><span>
</span><span id="line-83"></span><span class="hs-comment">-- readers are supported with a @dupSkipChan@ operation.</span><span>
</span><span id="line-84"></span><span class="hs-comment">--</span><span>
</span><span id="line-85"></span><span class="hs-comment">-- A skip channel is a pair of 'MVar's. The first 'MVar' contains the</span><span>
</span><span id="line-86"></span><span class="hs-comment">-- current value, and a list of semaphores that need to be notified</span><span>
</span><span id="line-87"></span><span class="hs-comment">-- when it changes. The second 'MVar' is a semaphore for this particular</span><span>
</span><span id="line-88"></span><span class="hs-comment">-- reader: it is full if there is a value in the channel that this</span><span>
</span><span id="line-89"></span><span class="hs-comment">-- reader has not read yet, and empty otherwise.</span><span>
</span><span id="line-90"></span><span class="hs-comment">--</span><span>
</span><span id="line-91"></span><span class="hs-comment">-- @</span><span>
</span><span id="line-92"></span><span class="hs-comment">--     data SkipChan a = SkipChan (MVar (a, [MVar ()])) (MVar ())</span><span>
</span><span id="line-93"></span><span class="hs-comment">--</span><span>
</span><span id="line-94"></span><span class="hs-comment">--     newSkipChan :: IO (SkipChan a)</span><span>
</span><span id="line-95"></span><span class="hs-comment">--     newSkipChan = do</span><span>
</span><span id="line-96"></span><span class="hs-comment">--         sem &lt;- newEmptyMVar</span><span>
</span><span id="line-97"></span><span class="hs-comment">--         main &lt;- newMVar (undefined, [sem])</span><span>
</span><span id="line-98"></span><span class="hs-comment">--         return (SkipChan main sem)</span><span>
</span><span id="line-99"></span><span class="hs-comment">--</span><span>
</span><span id="line-100"></span><span class="hs-comment">--     putSkipChan :: SkipChan a -&gt; a -&gt; IO ()</span><span>
</span><span id="line-101"></span><span class="hs-comment">--     putSkipChan (SkipChan main _) v = do</span><span>
</span><span id="line-102"></span><span class="hs-comment">--         (_, sems) &lt;- takeMVar main</span><span>
</span><span id="line-103"></span><span class="hs-comment">--         putMVar main (v, [])</span><span>
</span><span id="line-104"></span><span class="hs-comment">--         mapM_ (\sem -&gt; putMVar sem ()) sems</span><span>
</span><span id="line-105"></span><span class="hs-comment">--</span><span>
</span><span id="line-106"></span><span class="hs-comment">--     getSkipChan :: SkipChan a -&gt; IO a</span><span>
</span><span id="line-107"></span><span class="hs-comment">--     getSkipChan (SkipChan main sem) = do</span><span>
</span><span id="line-108"></span><span class="hs-comment">--         takeMVar sem</span><span>
</span><span id="line-109"></span><span class="hs-comment">--         (v, sems) &lt;- takeMVar main</span><span>
</span><span id="line-110"></span><span class="hs-comment">--         putMVar main (v, sem:sems)</span><span>
</span><span id="line-111"></span><span class="hs-comment">--         return v</span><span>
</span><span id="line-112"></span><span class="hs-comment">--</span><span>
</span><span id="line-113"></span><span class="hs-comment">--     dupSkipChan :: SkipChan a -&gt; IO (SkipChan a)</span><span>
</span><span id="line-114"></span><span class="hs-comment">--     dupSkipChan (SkipChan main _) = do</span><span>
</span><span id="line-115"></span><span class="hs-comment">--         sem &lt;- newEmptyMVar</span><span>
</span><span id="line-116"></span><span class="hs-comment">--         (v, sems) &lt;- takeMVar main</span><span>
</span><span id="line-117"></span><span class="hs-comment">--         putMVar main (v, sem:sems)</span><span>
</span><span id="line-118"></span><span class="hs-comment">--         return (SkipChan main sem)</span><span>
</span><span id="line-119"></span><span class="hs-comment">-- @</span><span>
</span><span id="line-120"></span><span class="hs-comment">--</span><span>
</span><span id="line-121"></span><span class="hs-comment">-- This example was adapted from the original Concurrent Haskell paper.</span><span>
</span><span id="line-122"></span><span class="hs-comment">-- For more examples of 'MVar's being used to build higher-level</span><span>
</span><span id="line-123"></span><span class="hs-comment">-- synchronization primitives, see 'Control.Concurrent.Chan' and</span><span>
</span><span id="line-124"></span><span class="hs-comment">-- 'Control.Concurrent.QSem'.</span><span>
</span><span id="line-125"></span><span class="hs-comment">--</span><span>
</span><span id="line-126"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-127"></span><span>
</span><span id="line-128"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">Control.Concurrent.MVar</span><span>
</span><span id="line-129"></span><span>        </span><span class="hs-special">(</span><span>
</span><span id="line-130"></span><span>          </span><span class="annot"><span class="hs-comment">-- * @MVar@s</span></span><span>
</span><span id="line-131"></span><span>          </span><span class="annot"><a href="GHC.MVar.html#MVar"><span class="hs-identifier">MVar</span></a></span><span>
</span><span id="line-132"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.MVar.html#newEmptyMVar"><span class="hs-identifier">newEmptyMVar</span></a></span><span>
</span><span id="line-133"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.MVar.html#newMVar"><span class="hs-identifier">newMVar</span></a></span><span>
</span><span id="line-134"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.MVar.html#takeMVar"><span class="hs-identifier">takeMVar</span></a></span><span>
</span><span id="line-135"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.MVar.html#putMVar"><span class="hs-identifier">putMVar</span></a></span><span>
</span><span id="line-136"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.MVar.html#readMVar"><span class="hs-identifier">readMVar</span></a></span><span>
</span><span id="line-137"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Control.Concurrent.MVar.html#swapMVar"><span class="hs-identifier">swapMVar</span></a></span><span>
</span><span id="line-138"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.MVar.html#tryTakeMVar"><span class="hs-identifier">tryTakeMVar</span></a></span><span>
</span><span id="line-139"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.MVar.html#tryPutMVar"><span class="hs-identifier">tryPutMVar</span></a></span><span>
</span><span id="line-140"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.MVar.html#isEmptyMVar"><span class="hs-identifier">isEmptyMVar</span></a></span><span>
</span><span id="line-141"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Control.Concurrent.MVar.html#withMVar"><span class="hs-identifier">withMVar</span></a></span><span>
</span><span id="line-142"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Control.Concurrent.MVar.html#withMVarMasked"><span class="hs-identifier">withMVarMasked</span></a></span><span>
</span><span id="line-143"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Control.Concurrent.MVar.html#modifyMVar_"><span class="hs-identifier">modifyMVar_</span></a></span><span>
</span><span id="line-144"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Control.Concurrent.MVar.html#modifyMVar"><span class="hs-identifier">modifyMVar</span></a></span><span>
</span><span id="line-145"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Control.Concurrent.MVar.html#modifyMVarMasked_"><span class="hs-identifier">modifyMVarMasked_</span></a></span><span>
</span><span id="line-146"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Control.Concurrent.MVar.html#modifyMVarMasked"><span class="hs-identifier">modifyMVarMasked</span></a></span><span>
</span><span id="line-147"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.MVar.html#tryReadMVar"><span class="hs-identifier">tryReadMVar</span></a></span><span>
</span><span id="line-148"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Control.Concurrent.MVar.html#mkWeakMVar"><span class="hs-identifier">mkWeakMVar</span></a></span><span>
</span><span id="line-149"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Control.Concurrent.MVar.html#addMVarFinalizer"><span class="hs-identifier">addMVarFinalizer</span></a></span><span>
</span><span id="line-150"></span><span>    </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-151"></span><span>
</span><span id="line-152"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.MVar.html"><span class="hs-identifier">GHC.MVar</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.MVar.html#MVar"><span class="hs-identifier">MVar</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.MVar.html#newEmptyMVar"><span class="hs-identifier">newEmptyMVar</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.MVar.html#newMVar"><span class="hs-identifier">newMVar</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.MVar.html#takeMVar"><span class="hs-identifier">takeMVar</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.MVar.html#putMVar"><span class="hs-identifier">putMVar</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-153"></span><span>                  </span><span class="annot"><a href="GHC.MVar.html#tryTakeMVar"><span class="hs-identifier">tryTakeMVar</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.MVar.html#tryPutMVar"><span class="hs-identifier">tryPutMVar</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.MVar.html#isEmptyMVar"><span class="hs-identifier">isEmptyMVar</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.MVar.html#readMVar"><span class="hs-identifier">readMVar</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-154"></span><span>                  </span><span class="annot"><a href="GHC.MVar.html#tryReadMVar"><span class="hs-identifier">tryReadMVar</span></a></span><span>
</span><span id="line-155"></span><span>                </span><span class="hs-special">)</span><span>
</span><span id="line-156"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="GHC.MVar.html"><span class="hs-identifier">GHC.MVar</span></a></span><span>
</span><span id="line-157"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Weak.html"><span class="hs-identifier">GHC.Weak</span></a></span><span>
</span><span id="line-158"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Base.html"><span class="hs-identifier">GHC.Base</span></a></span><span>
</span><span id="line-159"></span><span>
</span><span id="line-160"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Control.Exception.Base.html"><span class="hs-identifier">Control.Exception.Base</span></a></span><span>
</span><span id="line-161"></span><span>
</span><span id="line-162"></span><span class="hs-comment">{-|
  Take a value from an 'MVar', put a new value into the 'MVar' and
  return the value taken. This function is atomic only if there are
  no other producers for this 'MVar'.
-}</span><span>
</span><span id="line-167"></span><span id="local-6989586621679550927"><span class="annot"><a href="Control.Concurrent.MVar.html#swapMVar"><span class="hs-identifier hs-type">swapMVar</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.MVar.html#MVar"><span class="hs-identifier hs-type">MVar</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550927"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679550927"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550927"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-168"></span><span id="swapMVar"><span class="annot"><span class="annottext">swapMVar :: forall a. MVar a -&gt; a -&gt; IO a
</span><a href="Control.Concurrent.MVar.html#swapMVar"><span class="hs-identifier hs-var hs-var">swapMVar</span></a></span></span><span> </span><span id="local-6989586621679550862"><span class="annot"><span class="annottext">MVar a
</span><a href="#local-6989586621679550862"><span class="hs-identifier hs-var">mvar</span></a></span></span><span> </span><span id="local-6989586621679550861"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679550861"><span class="hs-identifier hs-var">new</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-169"></span><span>  </span><span class="annot"><span class="annottext">IO a -&gt; IO a
forall a. IO a -&gt; IO a
</span><a href="GHC.IO.html#mask_"><span class="hs-identifier hs-var">mask_</span></a></span><span> </span><span class="annot"><span class="annottext">(IO a -&gt; IO a) -&gt; IO a -&gt; IO a
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-170"></span><span>    </span><span id="local-6989586621679550859"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679550859"><span class="hs-identifier hs-var">old</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">MVar a -&gt; IO a
forall a. MVar a -&gt; IO a
</span><a href="GHC.MVar.html#takeMVar"><span class="hs-identifier hs-var">takeMVar</span></a></span><span> </span><span class="annot"><span class="annottext">MVar a
</span><a href="#local-6989586621679550862"><span class="hs-identifier hs-var">mvar</span></a></span><span>
</span><span id="line-171"></span><span>    </span><span class="annot"><span class="annottext">MVar a -&gt; a -&gt; IO ()
forall a. MVar a -&gt; a -&gt; IO ()
</span><a href="GHC.MVar.html#putMVar"><span class="hs-identifier hs-var">putMVar</span></a></span><span> </span><span class="annot"><span class="annottext">MVar a
</span><a href="#local-6989586621679550862"><span class="hs-identifier hs-var">mvar</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679550861"><span class="hs-identifier hs-var">new</span></a></span><span>
</span><span id="line-172"></span><span>    </span><span class="annot"><span class="annottext">a -&gt; IO a
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679550859"><span class="hs-identifier hs-var">old</span></a></span><span>
</span><span id="line-173"></span><span>
</span><span id="line-174"></span><span class="hs-comment">{-|
  'withMVar' is an exception-safe wrapper for operating on the contents
  of an 'MVar'.  This operation is exception-safe: it will replace the
  original contents of the 'MVar' if an exception is raised (see
  &quot;Control.Exception&quot;).  However, it is only atomic if there are no
  other producers for this 'MVar'.
-}</span><span>
</span><span id="line-181"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Control.Concurrent.MVar.html#withMVar"><span class="hs-pragma hs-type">withMVar</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-182"></span><span class="hs-comment">-- inlining has been reported to have dramatic effects; see</span><span>
</span><span id="line-183"></span><span class="hs-comment">-- http://www.haskell.org//pipermail/haskell/2006-May/017907.html</span><span>
</span><span id="line-184"></span><span id="local-6989586621679550915"><span id="local-6989586621679550916"><span class="annot"><a href="Control.Concurrent.MVar.html#withMVar"><span class="hs-identifier hs-type">withMVar</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.MVar.html#MVar"><span class="hs-identifier hs-type">MVar</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550916"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679550916"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550915"><span class="hs-identifier hs-type">b</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550915"><span class="hs-identifier hs-type">b</span></a></span></span></span><span>
</span><span id="line-185"></span><span id="withMVar"><span class="annot"><span class="annottext">withMVar :: forall a b. MVar a -&gt; (a -&gt; IO b) -&gt; IO b
</span><a href="Control.Concurrent.MVar.html#withMVar"><span class="hs-identifier hs-var hs-var">withMVar</span></a></span></span><span> </span><span id="local-6989586621679550854"><span class="annot"><span class="annottext">MVar a
</span><a href="#local-6989586621679550854"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span id="local-6989586621679550853"><span class="annot"><span class="annottext">a -&gt; IO b
</span><a href="#local-6989586621679550853"><span class="hs-identifier hs-var">io</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-186"></span><span>  </span><span class="annot"><span class="annottext">((forall a. IO a -&gt; IO a) -&gt; IO b) -&gt; IO b
forall b. ((forall a. IO a -&gt; IO a) -&gt; IO b) -&gt; IO b
</span><a href="GHC.IO.html#mask"><span class="hs-identifier hs-var">mask</span></a></span><span> </span><span class="annot"><span class="annottext">(((forall a. IO a -&gt; IO a) -&gt; IO b) -&gt; IO b)
-&gt; ((forall a. IO a -&gt; IO a) -&gt; IO b) -&gt; IO b
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679550851"><span class="annot"><span class="annottext">forall a. IO a -&gt; IO a
</span><a href="#local-6989586621679550851"><span class="hs-identifier hs-var">restore</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-187"></span><span>    </span><span id="local-6989586621679550850"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679550850"><span class="hs-identifier hs-var">a</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">MVar a -&gt; IO a
forall a. MVar a -&gt; IO a
</span><a href="GHC.MVar.html#takeMVar"><span class="hs-identifier hs-var">takeMVar</span></a></span><span> </span><span class="annot"><span class="annottext">MVar a
</span><a href="#local-6989586621679550854"><span class="hs-identifier hs-var">m</span></a></span><span>
</span><span id="line-188"></span><span>    </span><span id="local-6989586621679550849"><span class="annot"><span class="annottext">b
</span><a href="#local-6989586621679550849"><span class="hs-identifier hs-var">b</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IO b -&gt; IO b
forall a. IO a -&gt; IO a
</span><a href="#local-6989586621679550851"><span class="hs-identifier hs-var">restore</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a -&gt; IO b
</span><a href="#local-6989586621679550853"><span class="hs-identifier hs-var">io</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679550850"><span class="hs-identifier hs-var">a</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">IO b -&gt; IO () -&gt; IO b
forall a b. IO a -&gt; IO b -&gt; IO a
</span><a href="Control.Exception.Base.html#onException"><span class="hs-operator hs-var">`onException`</span></a></span><span> </span><span class="annot"><span class="annottext">MVar a -&gt; a -&gt; IO ()
forall a. MVar a -&gt; a -&gt; IO ()
</span><a href="GHC.MVar.html#putMVar"><span class="hs-identifier hs-var">putMVar</span></a></span><span> </span><span class="annot"><span class="annottext">MVar a
</span><a href="#local-6989586621679550854"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679550850"><span class="hs-identifier hs-var">a</span></a></span><span>
</span><span id="line-189"></span><span>    </span><span class="annot"><span class="annottext">MVar a -&gt; a -&gt; IO ()
forall a. MVar a -&gt; a -&gt; IO ()
</span><a href="GHC.MVar.html#putMVar"><span class="hs-identifier hs-var">putMVar</span></a></span><span> </span><span class="annot"><span class="annottext">MVar a
</span><a href="#local-6989586621679550854"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679550850"><span class="hs-identifier hs-var">a</span></a></span><span>
</span><span id="line-190"></span><span>    </span><span class="annot"><span class="annottext">b -&gt; IO b
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">b
</span><a href="#local-6989586621679550849"><span class="hs-identifier hs-var">b</span></a></span><span>
</span><span id="line-191"></span><span>
</span><span id="line-192"></span><span class="hs-comment">{-|
  Like 'withMVar', but the @IO@ action in the second argument is executed
  with asynchronous exceptions masked.

  @since 4.7.0.0
-}</span><span>
</span><span id="line-198"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Control.Concurrent.MVar.html#withMVarMasked"><span class="hs-pragma hs-type">withMVarMasked</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-199"></span><span id="local-6989586621679550846"><span id="local-6989586621679550847"><span class="annot"><a href="Control.Concurrent.MVar.html#withMVarMasked"><span class="hs-identifier hs-type">withMVarMasked</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.MVar.html#MVar"><span class="hs-identifier hs-type">MVar</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550847"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679550847"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550846"><span class="hs-identifier hs-type">b</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550846"><span class="hs-identifier hs-type">b</span></a></span></span></span><span>
</span><span id="line-200"></span><span id="withMVarMasked"><span class="annot"><span class="annottext">withMVarMasked :: forall a b. MVar a -&gt; (a -&gt; IO b) -&gt; IO b
</span><a href="Control.Concurrent.MVar.html#withMVarMasked"><span class="hs-identifier hs-var hs-var">withMVarMasked</span></a></span></span><span> </span><span id="local-6989586621679550841"><span class="annot"><span class="annottext">MVar a
</span><a href="#local-6989586621679550841"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span id="local-6989586621679550840"><span class="annot"><span class="annottext">a -&gt; IO b
</span><a href="#local-6989586621679550840"><span class="hs-identifier hs-var">io</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-201"></span><span>  </span><span class="annot"><span class="annottext">IO b -&gt; IO b
forall a. IO a -&gt; IO a
</span><a href="GHC.IO.html#mask_"><span class="hs-identifier hs-var">mask_</span></a></span><span> </span><span class="annot"><span class="annottext">(IO b -&gt; IO b) -&gt; IO b -&gt; IO b
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-202"></span><span>    </span><span id="local-6989586621679550839"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679550839"><span class="hs-identifier hs-var">a</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">MVar a -&gt; IO a
forall a. MVar a -&gt; IO a
</span><a href="GHC.MVar.html#takeMVar"><span class="hs-identifier hs-var">takeMVar</span></a></span><span> </span><span class="annot"><span class="annottext">MVar a
</span><a href="#local-6989586621679550841"><span class="hs-identifier hs-var">m</span></a></span><span>
</span><span id="line-203"></span><span>    </span><span id="local-6989586621679550838"><span class="annot"><span class="annottext">b
</span><a href="#local-6989586621679550838"><span class="hs-identifier hs-var">b</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">a -&gt; IO b
</span><a href="#local-6989586621679550840"><span class="hs-identifier hs-var">io</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679550839"><span class="hs-identifier hs-var">a</span></a></span><span> </span><span class="annot"><span class="annottext">IO b -&gt; IO () -&gt; IO b
forall a b. IO a -&gt; IO b -&gt; IO a
</span><a href="Control.Exception.Base.html#onException"><span class="hs-operator hs-var">`onException`</span></a></span><span> </span><span class="annot"><span class="annottext">MVar a -&gt; a -&gt; IO ()
forall a. MVar a -&gt; a -&gt; IO ()
</span><a href="GHC.MVar.html#putMVar"><span class="hs-identifier hs-var">putMVar</span></a></span><span> </span><span class="annot"><span class="annottext">MVar a
</span><a href="#local-6989586621679550841"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679550839"><span class="hs-identifier hs-var">a</span></a></span><span>
</span><span id="line-204"></span><span>    </span><span class="annot"><span class="annottext">MVar a -&gt; a -&gt; IO ()
forall a. MVar a -&gt; a -&gt; IO ()
</span><a href="GHC.MVar.html#putMVar"><span class="hs-identifier hs-var">putMVar</span></a></span><span> </span><span class="annot"><span class="annottext">MVar a
</span><a href="#local-6989586621679550841"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679550839"><span class="hs-identifier hs-var">a</span></a></span><span>
</span><span id="line-205"></span><span>    </span><span class="annot"><span class="annottext">b -&gt; IO b
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">b
</span><a href="#local-6989586621679550838"><span class="hs-identifier hs-var">b</span></a></span><span>
</span><span id="line-206"></span><span>
</span><span id="line-207"></span><span class="hs-comment">{-|
  An exception-safe wrapper for modifying the contents of an 'MVar'.
  Like 'withMVar', 'modifyMVar' will replace the original contents of
  the 'MVar' if an exception is raised during the operation.  This
  function is only atomic if there are no other producers for this
  'MVar'.
-}</span><span>
</span><span id="line-214"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Control.Concurrent.MVar.html#modifyMVar_"><span class="hs-pragma hs-type">modifyMVar_</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-215"></span><span id="local-6989586621679550907"><span class="annot"><a href="Control.Concurrent.MVar.html#modifyMVar_"><span class="hs-identifier hs-type">modifyMVar_</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.MVar.html#MVar"><span class="hs-identifier hs-type">MVar</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550907"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679550907"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550907"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span></span><span>
</span><span id="line-216"></span><span id="modifyMVar_"><span class="annot"><span class="annottext">modifyMVar_ :: forall a. MVar a -&gt; (a -&gt; IO a) -&gt; IO ()
</span><a href="Control.Concurrent.MVar.html#modifyMVar_"><span class="hs-identifier hs-var hs-var">modifyMVar_</span></a></span></span><span> </span><span id="local-6989586621679550835"><span class="annot"><span class="annottext">MVar a
</span><a href="#local-6989586621679550835"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span id="local-6989586621679550834"><span class="annot"><span class="annottext">a -&gt; IO a
</span><a href="#local-6989586621679550834"><span class="hs-identifier hs-var">io</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-217"></span><span>  </span><span class="annot"><span class="annottext">((forall a. IO a -&gt; IO a) -&gt; IO ()) -&gt; IO ()
forall b. ((forall a. IO a -&gt; IO a) -&gt; IO b) -&gt; IO b
</span><a href="GHC.IO.html#mask"><span class="hs-identifier hs-var">mask</span></a></span><span> </span><span class="annot"><span class="annottext">(((forall a. IO a -&gt; IO a) -&gt; IO ()) -&gt; IO ())
-&gt; ((forall a. IO a -&gt; IO a) -&gt; IO ()) -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679550833"><span class="annot"><span class="annottext">forall a. IO a -&gt; IO a
</span><a href="#local-6989586621679550833"><span class="hs-identifier hs-var">restore</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-218"></span><span>    </span><span id="local-6989586621679550832"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679550832"><span class="hs-identifier hs-var">a</span></a></span></span><span>  </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">MVar a -&gt; IO a
forall a. MVar a -&gt; IO a
</span><a href="GHC.MVar.html#takeMVar"><span class="hs-identifier hs-var">takeMVar</span></a></span><span> </span><span class="annot"><span class="annottext">MVar a
</span><a href="#local-6989586621679550835"><span class="hs-identifier hs-var">m</span></a></span><span>
</span><span id="line-219"></span><span>    </span><span id="local-6989586621679550831"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679550831"><span class="hs-identifier hs-var">a'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IO a -&gt; IO a
forall a. IO a -&gt; IO a
</span><a href="#local-6989586621679550833"><span class="hs-identifier hs-var">restore</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a -&gt; IO a
</span><a href="#local-6989586621679550834"><span class="hs-identifier hs-var">io</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679550832"><span class="hs-identifier hs-var">a</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">IO a -&gt; IO () -&gt; IO a
forall a b. IO a -&gt; IO b -&gt; IO a
</span><a href="Control.Exception.Base.html#onException"><span class="hs-operator hs-var">`onException`</span></a></span><span> </span><span class="annot"><span class="annottext">MVar a -&gt; a -&gt; IO ()
forall a. MVar a -&gt; a -&gt; IO ()
</span><a href="GHC.MVar.html#putMVar"><span class="hs-identifier hs-var">putMVar</span></a></span><span> </span><span class="annot"><span class="annottext">MVar a
</span><a href="#local-6989586621679550835"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679550832"><span class="hs-identifier hs-var">a</span></a></span><span>
</span><span id="line-220"></span><span>    </span><span class="annot"><span class="annottext">MVar a -&gt; a -&gt; IO ()
forall a. MVar a -&gt; a -&gt; IO ()
</span><a href="GHC.MVar.html#putMVar"><span class="hs-identifier hs-var">putMVar</span></a></span><span> </span><span class="annot"><span class="annottext">MVar a
</span><a href="#local-6989586621679550835"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679550831"><span class="hs-identifier hs-var">a'</span></a></span><span>
</span><span id="line-221"></span><span>
</span><span id="line-222"></span><span class="hs-comment">{-|
  A slight variation on 'modifyMVar_' that allows a value to be
  returned (@b@) in addition to the modified value of the 'MVar'.
-}</span><span>
</span><span id="line-226"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Control.Concurrent.MVar.html#modifyMVar"><span class="hs-pragma hs-type">modifyMVar</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-227"></span><span id="local-6989586621679550904"><span id="local-6989586621679550905"><span class="annot"><a href="Control.Concurrent.MVar.html#modifyMVar"><span class="hs-identifier hs-type">modifyMVar</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.MVar.html#MVar"><span class="hs-identifier hs-type">MVar</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550905"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679550905"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679550905"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">,</span><span class="annot"><a href="#local-6989586621679550904"><span class="hs-identifier hs-type">b</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550904"><span class="hs-identifier hs-type">b</span></a></span></span></span><span>
</span><span id="line-228"></span><span id="modifyMVar"><span class="annot"><span class="annottext">modifyMVar :: forall a b. MVar a -&gt; (a -&gt; IO (a, b)) -&gt; IO b
</span><a href="Control.Concurrent.MVar.html#modifyMVar"><span class="hs-identifier hs-var hs-var">modifyMVar</span></a></span></span><span> </span><span id="local-6989586621679550825"><span class="annot"><span class="annottext">MVar a
</span><a href="#local-6989586621679550825"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span id="local-6989586621679550824"><span class="annot"><span class="annottext">a -&gt; IO (a, b)
</span><a href="#local-6989586621679550824"><span class="hs-identifier hs-var">io</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-229"></span><span>  </span><span class="annot"><span class="annottext">((forall a. IO a -&gt; IO a) -&gt; IO b) -&gt; IO b
forall b. ((forall a. IO a -&gt; IO a) -&gt; IO b) -&gt; IO b
</span><a href="GHC.IO.html#mask"><span class="hs-identifier hs-var">mask</span></a></span><span> </span><span class="annot"><span class="annottext">(((forall a. IO a -&gt; IO a) -&gt; IO b) -&gt; IO b)
-&gt; ((forall a. IO a -&gt; IO a) -&gt; IO b) -&gt; IO b
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679550823"><span class="annot"><span class="annottext">forall a. IO a -&gt; IO a
</span><a href="#local-6989586621679550823"><span class="hs-identifier hs-var">restore</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-230"></span><span>    </span><span id="local-6989586621679550822"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679550822"><span class="hs-identifier hs-var">a</span></a></span></span><span>      </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">MVar a -&gt; IO a
forall a. MVar a -&gt; IO a
</span><a href="GHC.MVar.html#takeMVar"><span class="hs-identifier hs-var">takeMVar</span></a></span><span> </span><span class="annot"><span class="annottext">MVar a
</span><a href="#local-6989586621679550825"><span class="hs-identifier hs-var">m</span></a></span><span>
</span><span id="line-231"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621679550821"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679550821"><span class="hs-identifier hs-var">a'</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621679550820"><span class="annot"><span class="annottext">b
</span><a href="#local-6989586621679550820"><span class="hs-identifier hs-var">b</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IO (a, b) -&gt; IO (a, b)
forall a. IO a -&gt; IO a
</span><a href="#local-6989586621679550823"><span class="hs-identifier hs-var">restore</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a -&gt; IO (a, b)
</span><a href="#local-6989586621679550824"><span class="hs-identifier hs-var">io</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679550822"><span class="hs-identifier hs-var">a</span></a></span><span> </span><span class="annot"><span class="annottext">IO (a, b) -&gt; ((a, b) -&gt; IO (a, b)) -&gt; IO (a, b)
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; (a -&gt; m b) -&gt; m b
</span><a href="GHC.Base.html#%3E%3E%3D"><span class="hs-operator hs-var">&gt;&gt;=</span></a></span><span> </span><span class="annot"><span class="annottext">(a, b) -&gt; IO (a, b)
forall a. a -&gt; IO a
</span><a href="GHC.IO.html#evaluate"><span class="hs-identifier hs-var">evaluate</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">IO (a, b) -&gt; IO () -&gt; IO (a, b)
forall a b. IO a -&gt; IO b -&gt; IO a
</span><a href="Control.Exception.Base.html#onException"><span class="hs-operator hs-var">`onException`</span></a></span><span> </span><span class="annot"><span class="annottext">MVar a -&gt; a -&gt; IO ()
forall a. MVar a -&gt; a -&gt; IO ()
</span><a href="GHC.MVar.html#putMVar"><span class="hs-identifier hs-var">putMVar</span></a></span><span> </span><span class="annot"><span class="annottext">MVar a
</span><a href="#local-6989586621679550825"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679550822"><span class="hs-identifier hs-var">a</span></a></span><span>
</span><span id="line-232"></span><span>    </span><span class="annot"><span class="annottext">MVar a -&gt; a -&gt; IO ()
forall a. MVar a -&gt; a -&gt; IO ()
</span><a href="GHC.MVar.html#putMVar"><span class="hs-identifier hs-var">putMVar</span></a></span><span> </span><span class="annot"><span class="annottext">MVar a
</span><a href="#local-6989586621679550825"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679550821"><span class="hs-identifier hs-var">a'</span></a></span><span>
</span><span id="line-233"></span><span>    </span><span class="annot"><span class="annottext">b -&gt; IO b
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">b
</span><a href="#local-6989586621679550820"><span class="hs-identifier hs-var">b</span></a></span><span>
</span><span id="line-234"></span><span>
</span><span id="line-235"></span><span class="hs-comment">{-|
  Like 'modifyMVar_', but the @IO@ action in the second argument is executed with
  asynchronous exceptions masked.

  @since 4.6.0.0
-}</span><span>
</span><span id="line-241"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Control.Concurrent.MVar.html#modifyMVarMasked_"><span class="hs-pragma hs-type">modifyMVarMasked_</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-242"></span><span id="local-6989586621679550818"><span class="annot"><a href="Control.Concurrent.MVar.html#modifyMVarMasked_"><span class="hs-identifier hs-type">modifyMVarMasked_</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.MVar.html#MVar"><span class="hs-identifier hs-type">MVar</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550818"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679550818"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550818"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span></span><span>
</span><span id="line-243"></span><span id="modifyMVarMasked_"><span class="annot"><span class="annottext">modifyMVarMasked_ :: forall a. MVar a -&gt; (a -&gt; IO a) -&gt; IO ()
</span><a href="Control.Concurrent.MVar.html#modifyMVarMasked_"><span class="hs-identifier hs-var hs-var">modifyMVarMasked_</span></a></span></span><span> </span><span id="local-6989586621679550815"><span class="annot"><span class="annottext">MVar a
</span><a href="#local-6989586621679550815"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span id="local-6989586621679550814"><span class="annot"><span class="annottext">a -&gt; IO a
</span><a href="#local-6989586621679550814"><span class="hs-identifier hs-var">io</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-244"></span><span>  </span><span class="annot"><span class="annottext">IO () -&gt; IO ()
forall a. IO a -&gt; IO a
</span><a href="GHC.IO.html#mask_"><span class="hs-identifier hs-var">mask_</span></a></span><span> </span><span class="annot"><span class="annottext">(IO () -&gt; IO ()) -&gt; IO () -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-245"></span><span>    </span><span id="local-6989586621679550813"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679550813"><span class="hs-identifier hs-var">a</span></a></span></span><span>  </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">MVar a -&gt; IO a
forall a. MVar a -&gt; IO a
</span><a href="GHC.MVar.html#takeMVar"><span class="hs-identifier hs-var">takeMVar</span></a></span><span> </span><span class="annot"><span class="annottext">MVar a
</span><a href="#local-6989586621679550815"><span class="hs-identifier hs-var">m</span></a></span><span>
</span><span id="line-246"></span><span>    </span><span id="local-6989586621679550812"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679550812"><span class="hs-identifier hs-var">a'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">a -&gt; IO a
</span><a href="#local-6989586621679550814"><span class="hs-identifier hs-var">io</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679550813"><span class="hs-identifier hs-var">a</span></a></span><span> </span><span class="annot"><span class="annottext">IO a -&gt; IO () -&gt; IO a
forall a b. IO a -&gt; IO b -&gt; IO a
</span><a href="Control.Exception.Base.html#onException"><span class="hs-operator hs-var">`onException`</span></a></span><span> </span><span class="annot"><span class="annottext">MVar a -&gt; a -&gt; IO ()
forall a. MVar a -&gt; a -&gt; IO ()
</span><a href="GHC.MVar.html#putMVar"><span class="hs-identifier hs-var">putMVar</span></a></span><span> </span><span class="annot"><span class="annottext">MVar a
</span><a href="#local-6989586621679550815"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679550813"><span class="hs-identifier hs-var">a</span></a></span><span>
</span><span id="line-247"></span><span>    </span><span class="annot"><span class="annottext">MVar a -&gt; a -&gt; IO ()
forall a. MVar a -&gt; a -&gt; IO ()
</span><a href="GHC.MVar.html#putMVar"><span class="hs-identifier hs-var">putMVar</span></a></span><span> </span><span class="annot"><span class="annottext">MVar a
</span><a href="#local-6989586621679550815"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679550812"><span class="hs-identifier hs-var">a'</span></a></span><span>
</span><span id="line-248"></span><span>
</span><span id="line-249"></span><span class="hs-comment">{-|
  Like 'modifyMVar', but the @IO@ action in the second argument is executed with
  asynchronous exceptions masked.

  @since 4.6.0.0
-}</span><span>
</span><span id="line-255"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Control.Concurrent.MVar.html#modifyMVarMasked"><span class="hs-pragma hs-type">modifyMVarMasked</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-256"></span><span id="local-6989586621679550810"><span id="local-6989586621679550811"><span class="annot"><a href="Control.Concurrent.MVar.html#modifyMVarMasked"><span class="hs-identifier hs-type">modifyMVarMasked</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.MVar.html#MVar"><span class="hs-identifier hs-type">MVar</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550811"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679550811"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679550811"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">,</span><span class="annot"><a href="#local-6989586621679550810"><span class="hs-identifier hs-type">b</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550810"><span class="hs-identifier hs-type">b</span></a></span></span></span><span>
</span><span id="line-257"></span><span id="modifyMVarMasked"><span class="annot"><span class="annottext">modifyMVarMasked :: forall a b. MVar a -&gt; (a -&gt; IO (a, b)) -&gt; IO b
</span><a href="Control.Concurrent.MVar.html#modifyMVarMasked"><span class="hs-identifier hs-var hs-var">modifyMVarMasked</span></a></span></span><span> </span><span id="local-6989586621679550804"><span class="annot"><span class="annottext">MVar a
</span><a href="#local-6989586621679550804"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span id="local-6989586621679550803"><span class="annot"><span class="annottext">a -&gt; IO (a, b)
</span><a href="#local-6989586621679550803"><span class="hs-identifier hs-var">io</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-258"></span><span>  </span><span class="annot"><span class="annottext">IO b -&gt; IO b
forall a. IO a -&gt; IO a
</span><a href="GHC.IO.html#mask_"><span class="hs-identifier hs-var">mask_</span></a></span><span> </span><span class="annot"><span class="annottext">(IO b -&gt; IO b) -&gt; IO b -&gt; IO b
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-259"></span><span>    </span><span id="local-6989586621679550802"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679550802"><span class="hs-identifier hs-var">a</span></a></span></span><span>      </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">MVar a -&gt; IO a
forall a. MVar a -&gt; IO a
</span><a href="GHC.MVar.html#takeMVar"><span class="hs-identifier hs-var">takeMVar</span></a></span><span> </span><span class="annot"><span class="annottext">MVar a
</span><a href="#local-6989586621679550804"><span class="hs-identifier hs-var">m</span></a></span><span>
</span><span id="line-260"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621679550801"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679550801"><span class="hs-identifier hs-var">a'</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621679550800"><span class="annot"><span class="annottext">b
</span><a href="#local-6989586621679550800"><span class="hs-identifier hs-var">b</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a -&gt; IO (a, b)
</span><a href="#local-6989586621679550803"><span class="hs-identifier hs-var">io</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679550802"><span class="hs-identifier hs-var">a</span></a></span><span> </span><span class="annot"><span class="annottext">IO (a, b) -&gt; ((a, b) -&gt; IO (a, b)) -&gt; IO (a, b)
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; (a -&gt; m b) -&gt; m b
</span><a href="GHC.Base.html#%3E%3E%3D"><span class="hs-operator hs-var">&gt;&gt;=</span></a></span><span> </span><span class="annot"><span class="annottext">(a, b) -&gt; IO (a, b)
forall a. a -&gt; IO a
</span><a href="GHC.IO.html#evaluate"><span class="hs-identifier hs-var">evaluate</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">IO (a, b) -&gt; IO () -&gt; IO (a, b)
forall a b. IO a -&gt; IO b -&gt; IO a
</span><a href="Control.Exception.Base.html#onException"><span class="hs-operator hs-var">`onException`</span></a></span><span> </span><span class="annot"><span class="annottext">MVar a -&gt; a -&gt; IO ()
forall a. MVar a -&gt; a -&gt; IO ()
</span><a href="GHC.MVar.html#putMVar"><span class="hs-identifier hs-var">putMVar</span></a></span><span> </span><span class="annot"><span class="annottext">MVar a
</span><a href="#local-6989586621679550804"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679550802"><span class="hs-identifier hs-var">a</span></a></span><span>
</span><span id="line-261"></span><span>    </span><span class="annot"><span class="annottext">MVar a -&gt; a -&gt; IO ()
forall a. MVar a -&gt; a -&gt; IO ()
</span><a href="GHC.MVar.html#putMVar"><span class="hs-identifier hs-var">putMVar</span></a></span><span> </span><span class="annot"><span class="annottext">MVar a
</span><a href="#local-6989586621679550804"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679550801"><span class="hs-identifier hs-var">a'</span></a></span><span>
</span><span id="line-262"></span><span>    </span><span class="annot"><span class="annottext">b -&gt; IO b
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">b
</span><a href="#local-6989586621679550800"><span class="hs-identifier hs-var">b</span></a></span><span>
</span><span id="line-263"></span><span>
</span><span id="line-264"></span><span class="hs-pragma">{-# DEPRECATED</span><span> </span><span class="hs-pragma">addMVarFinalizer</span><span> </span><span class="hs-pragma">&quot;use 'mkWeakMVar' instead&quot;</span><span> </span><span class="hs-pragma">#-}</span><span> </span><span class="hs-comment">-- deprecated in 7.6</span><span>
</span><span id="line-265"></span><span id="local-6989586621679550895"><span class="annot"><a href="Control.Concurrent.MVar.html#addMVarFinalizer"><span class="hs-identifier hs-type">addMVarFinalizer</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.MVar.html#MVar"><span class="hs-identifier hs-type">MVar</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550895"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span></span><span>
</span><span id="line-266"></span><span id="addMVarFinalizer"><span class="annot"><span class="annottext">addMVarFinalizer :: forall a. MVar a -&gt; IO () -&gt; IO ()
</span><a href="Control.Concurrent.MVar.html#addMVarFinalizer"><span class="hs-identifier hs-var hs-var">addMVarFinalizer</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">MVar a -&gt; IO () -&gt; IO ()
forall a. MVar a -&gt; IO () -&gt; IO ()
</span><a href="GHC.MVar.html#addMVarFinalizer"><span class="hs-identifier hs-var">GHC.MVar.addMVarFinalizer</span></a></span><span>
</span><span id="line-267"></span><span>
</span><span id="line-268"></span><span class="hs-comment">-- | Make a 'Weak' pointer to an 'MVar', using the second argument as</span><span>
</span><span id="line-269"></span><span class="hs-comment">-- a finalizer to run when 'MVar' is garbage-collected</span><span>
</span><span id="line-270"></span><span class="hs-comment">--</span><span>
</span><span id="line-271"></span><span class="hs-comment">-- @since 4.6.0.0</span><span>
</span><span id="line-272"></span><span id="local-6989586621679550893"><span class="annot"><a href="Control.Concurrent.MVar.html#mkWeakMVar"><span class="hs-identifier hs-type">mkWeakMVar</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.MVar.html#MVar"><span class="hs-identifier hs-type">MVar</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550893"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Weak.html#Weak"><span class="hs-identifier hs-type">Weak</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.MVar.html#MVar"><span class="hs-identifier hs-type">MVar</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550893"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span></span><span>
</span><span id="line-273"></span><span id="mkWeakMVar"><span class="annot"><span class="annottext">mkWeakMVar :: forall a. MVar a -&gt; IO () -&gt; IO (Weak (MVar a))
</span><a href="Control.Concurrent.MVar.html#mkWeakMVar"><span class="hs-identifier hs-var hs-var">mkWeakMVar</span></a></span></span><span> </span><span id="local-6989586621679550798"><span class="annot"><span class="annottext">m :: MVar a
</span><a href="#local-6989586621679550798"><span class="hs-identifier hs-var">m</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.MVar.html#MVar"><span class="hs-identifier hs-type">MVar</span></a></span><span> </span><span id="local-6989586621679550796"><span class="annot"><span class="annottext">MVar# RealWorld a
</span><a href="#local-6989586621679550796"><span class="hs-identifier hs-var">m#</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span id="local-6989586621679550795"><span class="annot"><span class="annottext">State# RealWorld -&gt; (# State# RealWorld, () #)
</span><a href="#local-6989586621679550795"><span class="hs-identifier hs-var">f</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(State# RealWorld -&gt; (# State# RealWorld, Weak (MVar a) #))
-&gt; IO (Weak (MVar a))
forall a. (State# RealWorld -&gt; (# State# RealWorld, a #)) -&gt; IO a
</span><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-var">IO</span></a></span><span> </span><span class="annot"><span class="annottext">((State# RealWorld -&gt; (# State# RealWorld, Weak (MVar a) #))
 -&gt; IO (Weak (MVar a)))
-&gt; (State# RealWorld -&gt; (# State# RealWorld, Weak (MVar a) #))
-&gt; IO (Weak (MVar a))
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679550794"><span class="annot"><span class="annottext">State# RealWorld
</span><a href="#local-6989586621679550794"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-274"></span><span>    </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">MVar# RealWorld a
-&gt; MVar a
-&gt; (State# RealWorld -&gt; (# State# RealWorld, () #))
-&gt; State# RealWorld
-&gt; (# State# RealWorld, Weak# (MVar a) #)
</span><a href="../../ghc-prim/src/GHC.Prim.html#mkWeak%23"><span class="hs-identifier hs-var">mkWeak#</span></a></span><span> </span><span class="annot"><span class="annottext">MVar# RealWorld a
</span><a href="#local-6989586621679550796"><span class="hs-identifier hs-var">m#</span></a></span><span> </span><span class="annot"><span class="annottext">MVar a
</span><a href="#local-6989586621679550798"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">State# RealWorld -&gt; (# State# RealWorld, () #)
</span><a href="#local-6989586621679550795"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">State# RealWorld
</span><a href="#local-6989586621679550794"><span class="hs-identifier hs-var">s</span></a></span><span> </span><span class="hs-keyword">of</span><span> </span><span class="hs-special">(#</span><span> </span><span id="local-6989586621679550793"><span class="annot"><span class="annottext">State# RealWorld
</span><a href="#local-6989586621679550793"><span class="hs-identifier hs-var">s1</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679550792"><span class="annot"><span class="annottext">Weak# (MVar a)
</span><a href="#local-6989586621679550792"><span class="hs-identifier hs-var">w</span></a></span></span><span> </span><span class="hs-special">#)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(#</span><span> </span><span class="annot"><span class="annottext">State# RealWorld
</span><a href="#local-6989586621679550793"><span class="hs-identifier hs-var">s1</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Weak# (MVar a) -&gt; Weak (MVar a)
forall v. Weak# v -&gt; Weak v
</span><a href="GHC.Weak.html#Weak"><span class="hs-identifier hs-var">Weak</span></a></span><span> </span><span class="annot"><span class="annottext">Weak# (MVar a)
</span><a href="#local-6989586621679550792"><span class="hs-identifier hs-var">w</span></a></span><span> </span><span class="hs-special">#)</span><span>
</span><span id="line-275"></span></pre></body></html>